<?php

require_once 'include/connection.php';

$xxx = '001';
$mm = date('m');
$yyyy = date('Y');

$row = $db->QuerySingleRow("select max(numero) as ultimo from presupuestos where year = " . date('Y') . "");

if( $row-> ultimo == '' || $row-> ultimo == null){
    echo $xxx.$mm.'-'.$yyyy;
}else {
    $xxx=substr($row-> ultimo, 0,3);
    $xxx=$xxx+1;
    if($xxx<10){
        $xxx='00'.$xxx;
    }else if ($xxx<100) {
        $xxx='0'.$xxx;
    }
    echo $xxx.$mm.'-'.$yyyy;
}
?>
